﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using WebApplication2.Models;

namespace WebApplication2.DAL
{
    public class AccountInitializer:DropCreateDatabaseIfModelChanges<AccountContext>
    {
        protected override void Seed(AccountContext context)
        {
            var sysUsers = new List<SysUser>
            {
                new SysUser {UserName="zhou",Password="1",Email="as5101603@qq.com" },
                new SysUser {UserName="wang",Password="2",Email="277568333@qq.com"  }

            };

            sysUsers.ForEach(s => context.SysUsers.Add(s));
            context.SaveChanges();

            var sysRoles = new List<SysRole>
            {
                new SysRole {RoleName="管理员",RoleDesc="管理员的账户啦" },
                new SysRole {RoleName="财务",RoleDesc="管理财务的" },

            };
            sysRoles.ForEach(s => context.SysRoles.Add(s));
            context.SaveChanges();
        }

    }
}